from rediscluster import RedisCluster

# 集群节点
startup_nodes = [
    {"host": "172.20.151.167", "port": "7000"},
    {"host": "172.20.151.168", "port": "7001"},
    {"host": "172.20.151.169", "port": "7002"}
]

# 连接到 Redis 集群
rc = RedisCluster(startup_nodes=startup_nodes, decode_responses=True, password="coocaa2019.123")

keyword = 'bamboo-dev:translation:'
# 模糊搜索
keys = rc.scan_iter(match=f"{keyword}*")

results = []

for key in keys:
    print(f"redis key: {key}")
    results.append(rc.delete(f"{key}"))

print(f"redis key success")

